package com.banyuan.lesson.thread;

public class MyThread extends Thread {
    @Override
    public void run() {
        for (int i = 0; i < 100; i++) {
            System.out.println(this + "-" + i);
        }
        //让当前线程让步，也是一种建议；
        Thread.yield();
    }

    public static void main(String[] args) {
        MyThread th1 = new MyThread();
        MyThread th2 = new MyThread();
        //设置优先级 尽量让某个线程优先执行；
        th1.setPriority(Thread.MAX_PRIORITY);
        th2.setPriority(Thread.MIN_PRIORITY);
        //启动线程
        th1.start();
        th2.start();

        for (int i = 0; i < 100; i++) {
            System.out.println(Thread.currentThread() + "-" + i);
        }
    }
}
